

* IMPLEMENTS TEST OF NO CROSSING OF CDF AS IN ANGRIST-PISCHKE
* POINTWISE 95% CI OF DIFF BETWEEN G_info(E) G_notinfo(E) for values of E in -1(0.25)10

* time along rows and cdf along columns
* because latest qtrs have very high inflation, upper threshold of 10 has been raised to 20 in survey
* for comparability over time I top code everything at 10  

quietly{
use WorkingData, clear

mat def PR=J(42,46,0)
mat def SR=J(42,46,0)

local c=1
forvalues u=-1(0.25)10{
	cap drop dd
	gen dd=it12all<=$_u
	local r=1

	forvalues q=210/251{

		qui cap regr dd treat [aw=peso] if dp==$_q , r
		if _rc==0{
		mat PR[$_r,$_c] = _b[treat]
		mat SR[$_r,$_c] = _se[treat]
		}

		local r=$_r+1
	}
local c=$_c+1
}
drop _all


svmat PR
gen pr=209+_n
svmat SR
gen sr=209+_n
count if pr!=sr

drop pr 
rename sr dp
format dp %tq

reshape long PR SR, i(dp) j(b)

gen L=PR-1.96*SR
gen U=PR+1.96*SR

gen year=yofd(dofq(dp))
gen quarter=quarter(dofq(dp))
egen QQ=concat(year quarter), punct(":")
egen C=group(dp)
labmask C, val(QQ)

* here generate xaxis grid -1 to 10 with 0.25 inervals, same as points at which above regressions have been run
gen i=0.25
sort dp b
by dp: gen t= sum(i)
gen z=t-0.25
gen x=-1+z

* gen infl presented to firms

gen infl=.
forvalues j=1/42{
	replace infl=INFL[$_j,2] if dp==INFL[$_j,1]
}

gen high=0.5
gen low=-0.5

format x %3.0f

twoway rbar  U L  x , yaxis(1 2) barw(0.1) col(black) yli(0, lc(red))|| rbar high low infl, barw(0.02) col(red) /*lp(shortdash)*/ by(C, legend(off) note("") graphregion(c(white)) )  subti(,bc(white) ) xsize(20) ysize(20) xla(-1(1) 10, grid labsi(*0.8))  xmtick(-1(0.25)10) yla(, angle(0) grid) yla(, angle(0) grid axis(2)) xti("Expected inflation") yti("95% CI of difference between CDFs")  yti("", axis(2))
graph export FigTestNoCrossRobust_F1.eps, replace
}

* ===================================
* PRINT TO LOG DATA FOR FIG F1
* U, L upper/lower bound of 95%CI of coeff on assignment dummy; x gridpoints at which no crossing test run, C quarter
sort C x
list C U L x 
